<?php namespace Home\Controller;
use Hdphp\Controller\Controller;
class GoodsController extends Controller{
	private $GoodsModel;
	private $GoodsDetailModel;
	private $GoodsAttrModel;
	private $GoodsListModel;
	
	public function __init(){
		$this->GoodsModel=M('\Common\Model\sc_goods');
		$this->GoodsDetailModel=M('\Common\Model\sc_detail');
		$this->GoodsAttrModel=M('\Common\Model\sc_goods_attr');
	    $this->GoodsListModel=M('\Common\Model\sc_goods_list');
	}
	
	
	public function index(){
		
		//商品详情部分····································
		//获取商品详细信息
		$goodsDetailIfon=$this->GoodsDetailModel->getOneDetail();
		//处理大图（字符串转换数组）
		$goodsDetailIfon['big']=explode("|", $goodsDetailIfon['big']);
		//处理大图（字符串转换数组）
		$goodsDetailIfon['small']=explode("|", $goodsDetailIfon['small']);
		//商品详情数据
		View::with('goodsDetailIfon',$goodsDetailIfon);
        //商品详情部分结束····································
        
        
        //商品信息部分开始·····································
        $GoodsInfo=$this->GoodsModel->getOneGoods();
		$_SESSION['history'][]=$GoodsInfo;
		View::with('GoodsInfo', $GoodsInfo);
        //商品信息结束
        
        
        //商品属性部分开始
        $GoodsAttrInfo=$this->GoodsAttrModel->getGoodsListAttr();
		View::with('GoodsAttrInfo',$GoodsAttrInfo);
        //商品属性部分结束
			
		View::make();
	}
	
	
	
	
	
	
	

    public function check(){
    	$gid=Q('get.gid');
		$combine=implode(",", Q('get.combine'));
		
        $data=$this->GoodsListModel
               ->where("combine = '{$combine}' AND sc_goods_gid = '{$gid}'")
               ->find();

	    echo json_encode($data);
    }
	
}



?>